#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/16 23:14
# @Author: 刘航
# @Email: xxx@gmail.com
# @File：add_cust_care.py

"""
客户关怀界面
"""
from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from selenium.webdriver.support.select import Select

class CustCarePage(BasePage):
    add_cust_care_locator = (By.CSS_SELECTOR,".btn-primary > i:nth-child(1)")
    view_add_status_locator = (By.CSS_SELECTOR,".alert")
    select_locator = (By.ID,"field")
    input_search_locator = (By.ID,"search")
    dosearch_locator = (By.CSS_SELECTOR,"button.btn:nth-child(3)")
    care_title_locator = (By.CSS_SELECTOR,".table > tbody:nth-child(3) > tr:nth-child(1) > td:nth-child(2)")
    def cust_care_btn(self):
        """添加客户关怀按钮"""
        self.driver.find_element(*self.add_cust_care_locator).click()
    def view_add_status(self):
        data = self.driver.find_element(*self.view_add_status_locator).text
        return data
    def handle_select_box(self,select):
        """搜索下拉框选择"""
        element = self.driver.find_element(*self.select_locator)  # 操作下拉框
        Select(element).select_by_visible_text(select)
    def input_search(self,input_company):
        """方框输入主题"""
        self.driver.find_element(*self.input_search_locator).send_keys(input_company)  # 输入要搜索的公司
    def click_search(self):
        """点击搜索"""
        self.driver.find_element(*self.dosearch_locator).click()  # 点击搜索
    def view_care_title(self):
        """获取关怀主题"""
        data = self.driver.find_element(*self.care_title_locator).text  # 点击搜索
        return data
